<div class="container-fluid">
    <?php
//get item param from model
    $class = $viewModel->get('class');
    $courses = $viewModel->get('courses');
    if (!is_object($class)) {
        echo 'Classes is not exist!';
    } else {
        $arr = json_decode($class->params);
        if (!is_object($arr)) {
            $arrDayOfWeek = array();
        } else {
            $arrDayOfWeek = $arr->DayOfWeek;
        }
        ?>

        <h1>Update form</h1>
        <form class="form-horizontal" method="POST">
            <div class="control-group" style="display: none;">
                <label class="control-label" for="inputClassesID">Classes ID</label>
                <div class="controls">
                    <input type="text" id="inputClassesID" name="classes_id" value="<?php echo $class->classes_id; ?>">
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="inputClassesName">Classes Name</label>
                <div class="controls">
                    <input type="text" id="inputClassesName" name="classname" placeholder="Classes Name" value="<?php echo $class->classname; ?>" required="required">
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="inputCourseID">Course</label>
                <div class="controls">
                    <select id="inputCourseID" name="courses_id">
    <?php
    foreach ($courses as $course) {
        if ($course->courses_id == $class->courses_id) {
            $choice = "selected = 'selected'";
        } else {
            $choice = "";
        }
        echo "<option value='" . $course->courses_id . "'" . $choice . ">" . $course->courses_name . "</option>";
    }
    ?>
                    </select>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="inputKeywords">Keywords</label>
                <div class="controls">
                    <input type="text" id="inputKeywords" name="keyword"  value="<?php echo $class->keyword;
                    ?>" placeholder="Keywords">
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="inputDescription">Description</label>
                <div class="controls">
                    <textarea id="inputDescription" class="editor_noimage" name="description" placeholder="Description"  required="required" style="margin: 0px; height: 167px; width: 457px;"><?php echo $class->description; ?></textarea>
                </div>
            </div>
            <div class="control-group" >
                <label class="control-label" for="inputSubjectID">Day of week: </label>
                <div class="controls" id="sltDay"  style="">
                    <table class="table"> 
                        <tr>
                            <td><label>
                                    <input type="checkbox" class="sltDayOfWeek" name="sltDayOfWeek[]" value="2"  id="chkMonday" <?php echo (in_array(2, $arrDayOfWeek)) ? "checked" : ""; ?> />
                                    Monday</label></td>
                            <td><label>
                                    <input type="checkbox" class="sltDayOfWeek" name="sltDayOfWeek[]" value="3" id="chkTueday"  <?php echo (in_array(3, $arrDayOfWeek)) ? "checked" : ""; ?>/>
                                    Tuesday</label></td>
                            <td><label>
                                    <input type="checkbox" class="sltDayOfWeek" name="sltDayOfWeek[]" value="4" id="chkWednesday" <?php echo (in_array(4, $arrDayOfWeek)) ? "checked" : ""; ?>/>
                                    Wednesday</label></td>
                        </tr>
                        <tr>
                            <td><label>
                                    <input type="checkbox" class="sltDayOfWeek" name="sltDayOfWeek[]" value="5" id="chkThursday" <?php echo (in_array(5, $arrDayOfWeek)) ? "checked" : ""; ?> />
                                    Thursday</label></td>
                            <td><label>
                                    <input type="checkbox" class="sltDayOfWeek" name="sltDayOfWeek[]" value="6" id="chkFridays" <?php echo (in_array(6, $arrDayOfWeek)) ? "checked" : ""; ?>/>
                                    Friday</label></td>
                            <td><label>
                                    <input type="checkbox" class="sltDayOfWeek" name="sltDayOfWeek[]" value="7" id="chkSaturday" <?php echo (in_array(7, $arrDayOfWeek)) ? "checked" : ""; ?>/>
                                    Saturday</label></td>
                        </tr>
                    </table>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="inputUsername">Status</label>
                <div class="controls">
                    <select name="status">
                        <option value="0" <?php echo ($class->status == 0) ? "selected = 'selected'" : "" ?>>Deactive</option>
                        <option value="1" <?php echo ($class->status == 1) ? "selected = 'selected'" : "" ?>>Active</option>
                    </select>
                </div>
            </div>
            <div class="control-group">
                <div class="controls">
                    <button type="submit" class="btn btn-success">Submit</button>
                    <button type="reset" class="btn">Reset</button>
                </div>
            </div>
        </form>
<?php } ?>
</div>